import request from "../../utils/request";
import util from "../../utils/util";
Page({
    data: {
      staffList: [
        {
          id: 1,
          name: "张三",
          position: "物业经理",
          phone: "13800138000"
        },
        {
          id: 2,
          name: "李四",
          position: "维修人员",
          phone: "13900139000"
        },
        {
          id: 3,
          name: "王五",
          position: "客服人员",
          phone: "13700137000"
        }
      ]
    },
    callPhone(e) {
      const phone = e.currentTarget.dataset.phone;
      wx.makePhoneCall({
        phoneNumber: phone,
        success: () => {
          console.log("拨打电话成功");
        },
        fail: (err) => {
          console.error("拨打电话失败", err);
          wx.showToast({
            title: "拨打电话失败，请稍后重试",
            icon: "none"
          });
        }
      });
    },
    async onLoad(){
      //property-relations/user/<int:user_id>
      let userId=getApp().globalData.userInfo?.userId||1
      let data=await request.get("property-relations/user/"+userId);
      data = data.map(item => ({
        ...item.staff,
        phone:item.staff.tel
      }));
      this.setData({
            staffList:data,
      
      })
    }
  });